package com.qf.springboot230203.vo;

import java.util.HashMap;

/**
 *返回自定义消息
 */
/*@Data
@AllArgsConstructor
@NoArgsConstructor*/
public class ResultVo extends HashMap {

   /* private Integer code; //代表响应状态码
    private String msg; //接口自定义响应消息*/
    /*private Object data; //需要携带额外数据*/

    public static ResultVo ok(){
        ResultVo resultVo = new ResultVo();
        resultVo.put("code",1);
        resultVo.put("msg","ok");
        return resultVo;
    }

    public static ResultVo ok(String msg){
        ResultVo resultVo = new ResultVo();
        resultVo.put("code",1);
        resultVo.put("msg",msg);
        return resultVo;
    }

    public static ResultVo error(){
        ResultVo resultVo = new ResultVo();
        resultVo.put("code",-1);
        resultVo.put("msg","error");
        return resultVo;
    }

    /**
     * 封装通用错误json，接收自定义消息
     * @param msg
     * @return
     */
    public static ResultVo error(String msg){
        ResultVo resultVo = new ResultVo();
        resultVo.put("code",-1);
        resultVo.put("msg",msg);
        return resultVo;
    }

    /**
     * 封装通用错误json，接收自定义消息
     * @param msg
     * @return
     */
    public static ResultVo error(String msg,Integer code){
        ResultVo resultVo = new ResultVo();
        resultVo.put("code",code);
        resultVo.put("msg",msg);
        return resultVo;
    }
}
